<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false" import="com.brother.*"%> 
<%
String locale = "";
Cookie[] cookies = request.getCookies();
if(cookies != null){
	for(Cookie k: cookies){
		String name = k.getName();
		if(name.equals("language")){
			locale = k.getValue();
			break;
		}
	}
}
if(locale.length() == 0 && session.getAttribute("locale") == null) {
	java.util.Locale localeOb = request.getLocale();
	locale = localeOb.getLanguage(); 
	if(locale.equalsIgnoreCase("zh")) {
		locale = "zh";
	}else if(locale.equalsIgnoreCase("pt") || locale.equalsIgnoreCase("por")){
		locale = "pt";
	}else if(locale.equalsIgnoreCase("ind")) {
		locale = "ind";
	}else 
		locale = "en";
}

String previoursLocale = (String)session.getAttribute("locale");

if (locale.length() !=0 ) {
	session.setAttribute("locale",locale);
	if(locale.equals("en") || locale.equals("ind")){
		session.setAttribute(Constants.DATE_FORMAT_SESSION_NAME,"dd/MM/yyyy");
		session.setAttribute(Constants.EXT_DATE_FORMAT_SESSION_NAME,"d/m/Y");
	}else if(locale.equals("pt")){
		session.setAttribute(Constants.DATE_FORMAT_SESSION_NAME,"dd/MM/yyyy");
		session.setAttribute(Constants.EXT_DATE_FORMAT_SESSION_NAME,"d/m/Y");
	}else{
		session.setAttribute(Constants.DATE_FORMAT_SESSION_NAME,"yyyy-MM-dd");
		session.setAttribute(Constants.EXT_DATE_FORMAT_SESSION_NAME,"Y-m-d");
	}
}
System.out.println("session=" + session.getAttribute("locale"));
%>
<fmt:setLocale value="${sessionScope.locale}"/>
<fmt:setBundle basename="message"/>

